package com.example.lp.lpuicore.anim;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.Toast;

import com.example.lp.lpuicore.R;

/**
 * Author by lp,on 2021/7/1/001,14:20.
 */
abstract class BaseFragment extends Fragment {
    protected ImageView baseAnimView;
    private View view;

    abstract String getTitle();

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(getFragmentLayoutId(), container, false);
        baseAnimView = view.findViewById(R.id.anim_view);
        baseAnimView.setOnClickListener(v -> {
            Toast.makeText(getContext(), "点击view 当前位置：(" + baseAnimView.getX() + "，" + baseAnimView.getY() + ")", Toast.LENGTH_SHORT).show();
        });
        return view;
    }

    abstract int getFragmentLayoutId();

    protected View getFragmentView() {
        return view;
    }

    protected int[] getLoacation() {
        return new int[]{(int) baseAnimView.getX(), (int) baseAnimView.getY()};
    }
}
